/**
  ******************************************************************************
  * @file   dev_w25qxx.h  
  * @brief   
  * @author Peter
  * @version V0.0.2
  * @date 2022/08/15
  ******************************************************************************
*/
#ifndef _w25qxx_H
#define _w25qxx_H  

/* Public include -----------------------------------------------------------*/
#include "dev_include.h"

/* Public defines -----------------------------------------------------------*/
#define DEV_W25QXX_VERSION			"V0.0.3"

#define W25Q80 					0XEF13 	
#define W25Q16 					0XEF14
#define W25Q32 					0XEF15
#define W25Q64 					0XEF16
#define W25Q128					0XEF17
#define MF_ID_WINBOND               0xEF

/* Public enum -----------------------------------------------------------*/

/* Public Struct -----------------------------------------------------------*/
typedef struct
{
	drv_spi_t 		drv_spix;
	drv_gpio_t 		drv_gpio_spics;
    drv_gpio_t 		drv_gpio_wp;
    drv_gpio_t 		drv_gpio_reset;
    uint32_t 		mem_capacity_Byte;//容量Byte
} w25qxx_private_t;


typedef struct dev_w25qxx  dev_w25qxx_t;

struct dev_w25qxx
{
    /* ***************Public Parameter  *************** */
    const char *    DEV;            //设备名称
	
	const char *    DRV;            //SPI驱动名称
    const char *    PIN_CS;         //spi_cs-引脚
    const char *	PIN_MOSI;       //spi_mosi-引脚
    const char *	PIN_MISO;       //spi_miso-引脚
    const char *	PIN_SCK;        //spi_sck-引脚
	
    const char *	PIN_WP;         //写保护-引脚
    const char *	PIN_RESET;      //复位-引脚

	spi_speed_e 	SPI_SPEED;      //SPI速度
	spi_cs_e    	SPI_CS_MODE;    //SPI CS模式（软件，硬件）
	
	uint16_t 		mem_type;		//芯片型号
	/* ***************Private Method    *************** */
    void ( *Delay_ms ) (uint32_t);
    /* ***************Public Method     *************** */
	int ( *Read ) 	  		  (dev_w25qxx_t*, uint8_t* pBuffer,   uint32_t ReadAddr, 		uint32_t NumByteToRead );
	int ( *Write )	  		  (dev_w25qxx_t*, uint8_t* pBuffer,   uint32_t WriteAddr, 	    uint32_t NumByteToWrite );
	int ( *EraseSector )	  (dev_w25qxx_t*, uint32_t eraseaddr, uint32_t numbytetowrite );
	int ( *Check )	  		  (dev_w25qxx_t*);
    /* ***************Private Attributes*************** */
    w25qxx_private_t    private;

};
/* Public Variable ---------------------------------------------------------*/

//Pointer

//Array

//Const

/* Pubilc function prototypes -----------------------------------------------*/
int  		Dev_W25qxxInit           	(dev_w25qxx_t*);
											 
#endif
/******************* (C) COPYRIGHT 2020 Peter *****END OF FILE****/
